package com.hebeiboruan.common.exception;


import com.hebeiboruan.common.uitl.LoggerUtil;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 刘焕林
 * @date 2023/11/02
 *///当前工程所有异常的父类异常
public class CommonException extends RuntimeException{


    public CommonException(ServiceResultEnum code,Exception e){
        super(code.getResult());
        this.errorCode = code.getErrorCode();
        LoggerUtil.error(e);
    }
    public CommonException(ServiceResultEnum code){
        super(code.getResult());
        this.errorCode = code.getErrorCode();
        LoggerUtil.error(code.getResult());
    }
    public CommonException(ServiceResultEnum code, Exception e, HttpServletRequest request){
        super(code.getResult());
        this.errorCode = code.getErrorCode();
        LoggerUtil.webError(e,request);
    }

    public CommonException(String message) {
        super(message);
    }
    public CommonException(String errorCode, String message){
        super(message);
        this.errorCode = errorCode;
    }

    protected String errorCode;

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
}
